db = db.getSiblingDB("admin");

// 查询 root 用户是否存在
var user = db.getUser("root");

if (!user) {
    db.createUser({
        user: "root",
        pwd: "root",
        roles: [ { role: "root", db: "admin" } ]
    });
    print("Root user created.");
} else {
    print("Root user already exists, skipping creation.");
}
